package airplay.droidairplay;

import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import javax.crypto.Cipher;

import nz.co.iswe.android.airplay.AirPlayServer;

public class MainActivity extends Activity {
    private Button button;
    public static ProgressDialog pd;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        button = (Button) findViewById(R.id.button);


        // 打开AirPlay
        String transformation = "RSA/None/OAEPWithSHA1AndMGF1Padding";
        try {
            Cipher rsaPkCS1OaepCipher = Cipher
                    .getInstance(transformation);
        } catch (Exception e) {
            e.printStackTrace();
        }

        AirPlayServer airPlayServer = AirPlayServer.getIstance();

        airPlayServer.setRtspPort(5000);

        Thread thread = new Thread(airPlayServer);
        thread.start();
        pd = ProgressDialog.show(this,"","正在开启服务，请稍后。。。");

        System.out.println("开启AirPlay");

//        button = (Button) findViewById(R.id.button);
//        button.setOnClickListener(new OnClickListener());

    }

    /**
     * 点击事件
     */
    public class OnClickListener implements View.OnClickListener{

        @Override
        public void onClick(View v) {

            // 打开AirPlay
            String transformation = "RSA/None/OAEPWithSHA1AndMGF1Padding";
            try {
                Cipher rsaPkCS1OaepCipher = Cipher
                        .getInstance(transformation);
            } catch (Exception e) {
                e.printStackTrace();
            }

            AirPlayServer airPlayServer = AirPlayServer.getIstance();

            airPlayServer.setRtspPort(5000);

            Thread thread = new Thread(airPlayServer);
            thread.start();

            System.out.println("开启AirPlay");

        }
    }
}
